home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Tools & Utilities
/
Collection of Tools and Utilities.iso
/
turbovis
/
ned103.zip
/
EDITPKG.PAS
< prev
next >
Wrap
Pascal/Delphi Source File
|
1992-08-28
|
34KB
|
1,156 lines
{ FILE: editpkg.pas }
unit EditPkg;
{ ************************************************************************* }
{ }
{ NOTICE: Most of the following code was written by Borland International. }
{ The code is for use by TP6.0 users. Keep the copyright notice }
{ intact! }
{ }
{ Turbo Pascal 6.0 }
{ Turbo Vision Demo }
{ Copyright (c) 1990 by Borland International }
{ }
{ This unit provides an interface to the NEWEDIT unit. Specifically, }
{ it initializes the buffers, contains all the editor dialogs, handles all }
{ allocation and deallocation of the clipboard, and of course opens up }
{ the appropriate edit window when requested. }
{ }
{ The major item I've changed here is how the "heap" is set up for }
{ use by the editor buffers. You can search for it using the HEAP }
{ shown below. }
{ }
{ In addition, I've added a procedure to show how to close editor windows }
{ for external file processing and then reopen them to continue editing. }
{ Look for the CHKSPL label. This label is also defined in NEDEMO and }
{ NEWEDIT, for it requires coding through all three units. }
{ }
{ All other labels in this unit are defined in the NEWEDIT }
{ unit, they being mostly for dialog boxes and error messages. }
{ }
{ There are additional minor things, like how to use typecasting to set }
{ editor defaults when opening a window. These aren't labeled. }
{ }
{ Search Description: }
{ ------ ------------ }
{ }
{ HEAP - Added a feature to allow maximum or minimum heap allocation }
{ for use by the editors buffers. }
{ }
{ SPLCHK - Shows how to close an edit window to process a file }
{ (such as spell checking) and reopen the window when done. }
{ }
{ Al Andersen - 02/29/92. }
{ }
{ ************************************************************************* }
{$O+,F+,X+,S-,D-}
interface
uses
Objects,
Drivers,
Views,
Dialogs,
StdDlg,
MsgBox,
App,
Buffers,
CmdFile,
NewEdit;
VAR
Clip_Window : NewEdit.PEditWindow; { Object to hold the clip board. }
{ SPLCHK - Start. }
procedure SpellIt;
{ SPLCHK - Stop. }
procedure Deallocate_The_Clipboard;
procedure Deallocate_The_Editor;
procedure Initialize_The_Clipboard;
procedure Initialize_The_Editor;
function Open_Editor (File_Name : Objects.FNameStr;
Visible : Boolean) : NewEdit.PEditWindow;
procedure Run_The_Editor;
procedure Show_ClipBoard;
implementation
{ -------------------------------------------------------------------------- }
{ SPLCHK - Start. }
Procedure SpellIt;
{ ---------------------------------------------------------------------- }
{ }
{ This procedure demonstrates how to close an editor window for external }
{ file processing, and then reopen the window to continue editing. The }
{ procedure assumes an external spell checking program will be used. }
{ }
{ ---------------------------------------------------------------------- }
VAR
SpellFileName : Objects.FNameStr; { Determines what the filename is. }
begin
{ ----------------------------------------------------------- }
{ }
{ First we check to make sure that the current window is in }
{ fact an editor window. We need to do this so you don't run }
{ the spelling checker unless an edit window is being used. }
{ }
{ ----------------------------------------------------------- }
if typeof (Desktop^.Current^) = typeof (TEditWindow) then
begin
{ --------------------------------------------------------- }
{ }
{ OK, now get the filename associated with the current edit }
{ window. Then send a message to NewEdit.TFileEditor's }
{ HandleEvent method to write the data to disk and close }
{ the window. You need to *REMOVE* the dialog and insert }
{ your spell checking code in its place. Last of all you }
{ call Open_Editor to reopen your edit window. }
{ }
{ --------------------------------------------------------- }
SpellFileName := NewEdit.PEditWindow (Desktop^.Current)^.Editor^.FileName;
Message (Desktop^.Current,
Drivers.evCommand,
NewEdit.cmSaveDone,
nil);
Msgbox.MessageBox (^C'Now your spellchecker does its thing.',
nil, MsgBox.mfInformation + MsgBox.mfOKButton);
Open_Editor (SpellFileName, True);
end;
end; { SpellIt }
{ SPLCHK - Stop. }
{ -------------------------------------------------------------------------- }
function Execute_Dialog (P : Dialogs.PDialog; Data : Pointer) : Word;
{ -------------------------------------------------------- }
{ }
{ This function places the editor dialogs on the desktop }
{ and takes care of seting/getting data options from them. }
{ }
{ -------------------------------------------------------- }
VAR
Result : Word; { Holds result of trying to ExecView onto Desktop. }
begin
Result := Views.cmCancel;
P := PDialog (App.Application^.ValidView (P));
if P <> nil then
begin
if Data <> nil then
P^.SetData (Data^);
Result := App.DeskTop^.ExecView (P);
if (Result <> Views.cmCancel) and (Data <> nil) then
P^.GetData (Data^);
Dispose (P, Done);
end;
Execute_Dialog := Result;
end; { Execute_Dialog }
{ -------------------------------------------------------------------------- }
function Do_Edit_Dialog (Dialog : Integer; Info : Pointer) : Word; far;
{ ---------------------------------------------------------- }
{ }
{ This function creates the appropriate editor dialog boxes. }
{ }
{ ---------------------------------------------------------- }
VAR
Y_Position : Word; { Local variable to ensure ALL dialogs start in same spot. }